
import Vuex from 'vuex'
import Vue from 'vue'
Vue.use(Vuex)
export default new Vuex.Store({
  state: {
    apps: [{
      appId: 1,
      icon: 'https://portfolio.zxh.io/img/icons/facetime.png',
      width: 300,
      height: 300,
      dock: true,
      title: 'facetime',
      compName: 'facetime',
      open: false,//是否打开
      min: false,//最小化
      max: false//最大化
    },
    {
      appId: 2,
      icon: 'https://portfolio.zxh.io/img/icons/safari.png',
      width: 350,
      height: 200,
      dock: true,
      title: 'safari',
      compName: 'safari',
      open: false,//是否打开
      min: false,//最小化
      max: false//最大化
    },
    {
      appId: 3,
      icon: 'https://portfolio.zxh.io/img/icons/vscode.png',
      width: 400,
      height: 500,
      dock: true,
      title: 'vscode',
      compName: 'vscode',
      open: false,//是否打开
      min: false,//最小化
      max: false//最大化
    },
    {
      appId: 4,
      icon: 'https://portfolio.zxh.io/img/icons/mail.png',
      width: 400,
      height: 500,
      dock: true,
      title: 'email',
      compName: 'email',
      open: false,//是否打开
      min: false,//最小化
      max: false//最大化
    }

    ]
  },
  actions: {
    minApp({ state }, appId) {
      const app = state.apps.find(item => item.appId === appId)
      if (app) {
        app.min = true
      }

    },
    maxApp({ state }, appId) {

      const app = state.apps.find(item => item.appId === appId)
      if (app) {
        app.max = true
      }
    },
    closeApp({ state }, appId) {

      const app = state.apps.find(item => item.appId === appId)
      if (app) {
        app.open = false
      }
    },
    openApp({ state }, appId) {
      console.log('!!!', appId)
      const app = state.apps.find(item => item.appId === appId)
      if (app) {
        app.open = true
        app.min = false
      }
    }

  }
})